package com.etooling.framework.repository;


import com.etooling.framework.entity.Role;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository
public interface RoleRepository extends BaseRepository<Role> {

    @Query(nativeQuery = true, value = "select * from framework.t_role where id in(?1)")
    List<Role> getByIds(List ids);


    @Query(nativeQuery = true, value = "select * from framework.t_role where name =?1 limit 1")
    Role getOneByName(String roleName);

    @Query(nativeQuery = true,value = "select * from framework.t_role where id in (select role_id from framework.t_employee_role where employee_id = ?1 )")
    List<Role> getById(String userId);
}
